SetGfxDriver 1:Graphics 1024,600,8,2 :SetBuffer FrontBuffer() :SeedRnd MilliSecs()
Global prostir$,in1,in2,in3,in4,sort1,sort2,zzz1,hzzz1,jzzz1,out$
in1 = CreateBank(100 ):in2 = CreateBank(100):in3 = CreateBank(100):in4 = CreateBank(100)
Dim aaa(60):Dim aaa1(60):Dim aaa2(60):sort1 = CreateBank(80):sort2 = CreateBank(60)
Dim zzz(66666):Dim zzz2(8881,100):Dim hzzz2(8881,100):Dim hzzz(66666):Dim jzzz2(8881,100):Dim jzzz(66666)


prostir="0010100101010110010111010101001011"
While Not KeyHit(1) Or MouseHit(2)
ClsColor 0,0,0
Cls
randnum(0)
getnums()
;	fact_faza():erase()
Text 510,40,uu,False ,False

;checke()

zzz1=zzz1+1:hzzz1=hzzz1+1:jzzz1=jzzz1+1
Flip
If zzz1> 9    Then 
 WaitMouse()
randnum(1)
EndIf

VWait 
Wend 

Function erase()

		
End Function

Function fact_faza()
;If bit <>2 Then	
t1=Rand(1,4):t2=Rand(1,4):t3=Rand(1,4):t4=Rand(1,4):t5=Rand(1,4):t6=Rand(1,4)

eee1=(t1 Xor t2) Xor t6:eee2=(t2 Xor t1) Xor t5:eee3=(t3 Xor t2) Xor t1
eee4=(t4 Xor t1) Xor t2:eee5=(t5 Xor t4) Xor t1:eee6=(t6 Xor t4) Xor t3

eee1=Rand(1,4):eee2=Rand(1,4):eee3=Rand(1,4):eee4=Rand(1,4):eee5=Rand(1,4):eee6=Rand(1,4)

For it1=1 To 4
For it2=1 To 4
For it3=1 To 4
For it4=1 To 4
For it5=1 To 4
For it6=1 To 4

ee1= (it1 Xor it2) Xor it6
ee2= (it2 Xor it1) Xor it5
ee3= (it3 Xor it2) Xor it1
ee4= (it4 Xor it1) Xor it2
ee5= (it5 Xor it4) Xor it1
ee6= (it6 Xor it4) Xor it3


If  (ee1=eee1) And (ee2=eee2)And (ee3=eee3)And(ee4=eee4) And (ee5=eee5)And (ee6=eee6)Then zzz(zzz1)=zzz(zzz1)+1:zzz2(zzz1,zzz2(zzz1,100))=it1:its=it1:zzz2(zzz1,100)=zzz2(zzz1,100)+1
		;If zzz2(zzz1,100)=0 Then 
		zzz2(zzz1,99)=eee:its=eee
	Next
	Next
	Next
	Next
	Next
	Next
			
;Next					
				
;Else


	
;EndIf 	



End Function


























Function mod2(x)
While x>6
 x = x -6
Wend 
While  x<1 
 x = x +6
Wend 
Return x
End Function

Function mod1(x)
While x>4
 x = x -1073741824
Wend 
While  x<0 
 x = x +1073741824
Wend 
Return x
End Function

Function randnum(bt)

For i = 0 To 9
t = Rand(0,3):PokeByte in1,i, t:PokeByte in2,i, t
Next

If bt=1 Then
For i=0 To 30
zzz1=0:jzzz1=0:hzzz1=0:tycnt=0
hzzz(i)=0:zzz(i)=0:jzzz(i)=0
Next
For i1=0 To 8881
For i2=0 To 100
jzzz2(i1,i2)=0
zzz2(i1,i2)=0
hzzz2(i1,i2)=0
Next
Next
EndIf

End Function


Function getnums()
	For y=0 To 9
	For x=0 To 5
		Color 0,255,0:Text 30+x*9,y*9+10,PeekByte(in1,y*10+x),False ,False 
	Next
	Next

	fact_faza()
	erase()
	
	For y=0 To 2
	For x=0 To 2
	Color 255,255,0:Text 230+x*16,y*9+10,PeekByte(in2,(y*7+x)),False ,False 
	Next
	Next
;	xx1=fact(PeekInt(in2,0),PeekInt(in2,5),PeekInt(in2,10))
;	xx2=fact(PeekInt(in2,0+15),PeekInt(in2,5+15),PeekInt(in2,10+15))
;	xx3=fact(PeekInt(in2,0+2*15),PeekInt(in2,5+2*15),PeekInt(in2,10+2*15))
;	lxx1 = fact(xx1,xx2,xx3)
	Text 160,62,lxx1,False ,False 

;	xx1=fact(PeekInt(in2,0),PeekInt(in2,0+15),PeekInt(in2,0+2*15))
;	xx2=fact(PeekInt(in2,5),PeekInt(in2,5+15),PeekInt(in2,5+2*15))
;	xx3=fact(PeekInt(in2,10),PeekInt(in2,10+15),PeekInt(in2,10+2*15))
;	lxx2 = fact(xx1,xx2,xx3)
	Text 190,62,lxx2,False ,False :Text 210,62,lxx1*6+lxx2,False ,False 	
	
;         STAT
;	For i=0 To hzzz1
;		;If zzz(i) = 0 Then ttt0 = ttt0+1
;		ttt0 = ttt0+hzzz(i)
;		Color 155,255,0:Text 15+(i*19) Mod 960,180+68*Int(i/80),Str(hzzz(i))+",",False ,False 
;			For i9=0 To hzzz2(i,100)-1
;			Color hzzz2(i,i9)*21,hzzz2(i,i9)*51,255:Text 15+(i*19) Mod 960,180+68*Int(i/80)+i9*10+10,Str(hzzz2(i,i9))+"",False ,False 	
;			Next	
;		If hzzz2(i,100) = 0 Then 
;		Color 155,hzzz2(i,99)*51,hzzz2(i,99)*51:Text 15+(i*19) Mod 960,180+68*Int(i/80)-7,Str(hzzz2(i,99))+"",False ,False 	
;		EndIf 
;    Next
;
	For i=0 To jzzz1
		;If zzz(i) = 0 Then ttt0 = ttt0+1
		ttt0 = ttt0+jzzz(i)
		Color 105,255,0:Text 15+(i*9) Mod 960,155+68*Int(i/100),Str(jzzz(i))+",",False ,False 
			For i9=0 To jzzz2(i,100)-1
			Color jzzz2(i,i9)*21,jzzz2(i,i9)*51,155:Text 15+(i*9) Mod 960,155+68*Int(i/100)+i9*10+10,Str(jzzz2(i,i9))+"",False ,False 	
			Next	
		If jzzz2(i,100) = 0 Then 
		Color 105,jzzz2(i,99)*51,jzzz2(i,99)*51:Text 15+(i*9) Mod 960,155+68*Int(i/100)-7,Str(jzzz2(i,99))+"",False ,False 	
		EndIf 
    Next
	
	ttt0=0:wnullmax=0
	For i=0 To zzz1
		If zzz(i) = 0 Then 
			cnull = cnull +1
			If wnullmax < wnullmax0 Then wnullmax = wnullmax0
			wnullmax0=0
		EndIf
		If zzz(i) <> 0 Then wnullmax0=wnullmax0+1
		;If zzz(i) = 0 Then ttt0 = ttt0+1
		ttt0 = ttt0+zzz(i)
		Color 255,255,0:Text 15+(i*19) Mod 950,110+68*Int(i/100),Str(zzz(i))+",",False ,False 
			For i9=0 To zzz2(i,100)-1
			Color zzz2(i,i9)*51,zzz2(i,i9)*51,255:Text 15+(i*19) Mod 950,110+68*Int(i/100)+i9*10+10,Str(zzz2(i,i9))+"",False ,False 	
			Next	
		If zzz2(i,100) = 0 Then 
		Color 255,zzz2(i,99)*51,zzz2(i,99)*51:Text 15+(i*19) Mod 950,110+68*Int(i/100)-7,Str(zzz2(i,99))+"",False ,False 	
		EndIf 
    Next
	cnull = Ceil(cnull * 100 /  (zzz1+1))
	tnull = Ceil(tycnt* 100 /  (zzz1+1))

	Color 255,0,0:
	If bit=2 Text 140,89,"-",False ,False Else Color 0,255,0:Text 70,89,"+"

	Color 255,255,210:Text 10,95,tycnt+" maxfase1: "+maxfase1+" minfase2: "+minfase2+"  middle=" + ttt0+"/"+ zzz1 + ", One cnt=" + cnull+"%, max without Null="+wnullmax+", phase=4",False ,False

End Function





